﻿@{
    Layout = "~/Views/Shared/OA/_Index.cshtml";
    //模拟登陆，显示菜单
    var article = IoCHeler.Resolve<IArticleAppService>().GetArticle(ConvertHelper.ToGuid(Request["catalogId"]));
    var qphId = Request["qphId"];
    if (!string.IsNullOrEmpty(qphId))
    {
        var qph = IoCHeler.Resolve<IArticleAppService>().GetArticle(ConvertHelper.ToGuid(qphId));
        AssertHelper.NoPass(qph == null, "未找到汽派号");
    }
    else {
        AssertHelper.NoPass(true, "未找到汽派号");
    }
}
@section Toolbar
{
    <button class="k-button" onclick="create()"><span class="i i-create"></span>新建</button>
    <button class="k-button" onclick="modify()"><span class="i i-modify"></span>修改</button>
    <button class="k-button" onclick="setTop()"><span class="i i-setTop"></span>置顶</button>
    <button class="k-button" onclick="moveUp()"><span class="i i-moveUp"></span>上移</button>
    <button class="k-button" onclick="moveDown()"><span class="i i-moveDown"></span>下移</button>
    <button class="k-button" onclick="removee()"><span class="i i-removee"></span>删除</button>
    <button class="k-button" onclick="refresh()"><span class="i i-reload"></span>刷新</button>

}
@section Menu
{
    <li onclick="modify()">修改</li>
    <li onclick="removee()">删除</li>

    @*@Html.MyNet().Menu(new ButtonOptions { Text = "修改", Click = "modify" })
    @Html.MyNet().Menu(new ButtonOptions { Text = "删除", Click = "removee" })*@
}
@section Query
{
    @Html.Partial("_Query", new ArticleCondition())
}
@section Main
{
    <div id="grid" class="grid">
    </div>
    <div id="pager" class="pager">
    </div>
}
<script type="text/javascript">

    var url = "/CMS/Article/";
    var urlSignup = "/CMS/Signup/";
    var catalogKey = "qph";
    var qphId = '@qphId';

    jQuery(function () {
        read();
    });

    function read() {
        query.CatalogKey = catalogKey;
        query.Origin = qphId;
        $.ajax
            ({
                url: url + "Read",
                data: query,
                type: "post",
                error: disposeError,
                success: function (result) {

                    if (disposeException(result)) return;
                    bind(result);
                }
            });
    }

    function create() {
        navThis(url + "Create?CatalogKey=" + catalogKey + "&back=thisBack&qphId=" + qphId);
    }

    function modify() {
        if (!gridSelected()) return alert("未选中任何数据！");
        navThis(url + "Modify?Id=" + gridSelected() + "&back=thisBack&qphId=" + qphId);
    }

    function removee() {
        if (!gridSelected()) return alert("未选中任何数据！");
        if (!confirm("确定要删除选中的数据吗？")) return;

        $.ajax
            ({
                url: url + "Remove",
                data: { ids: gridSelected() },
                type: "post",
                error: disposeError,
                success: function (result) {
                    if (disposeException(result)) return;

                    read();
                }
            });
    }

    function setTop() {
        if (!gridSelected()) return alert("未选中任何数据！");

        $.ajax
            ({
                url: url + "SetTop",
                data: { ids: gridSelected() },
                type: "post",
                error: disposeError,
                success: function (result) {
                    if (disposeException(result)) return;
                    read();
                }
            });
    }

    function moveUp() {
        if (!gridSelected()) return alert("未选中任何数据！");

        $.ajax
            ({
                url: url + "MoveUp",
                data: { id: gridSelected()[0] },
                type: "post",
                error: disposeError,
                success: function (result) {
                    if (disposeException(result)) return;
                    read();
                }
            });
    }

    function moveDown() {
        if (!gridSelected()) return alert("未选中任何数据！");

        $.ajax
            ({
                url: url + "MoveDown",
                data: { id: gridSelected()[0] },
                type: "post",
                error: disposeError,
                success: function (result) {
                    if (disposeException(result)) return;
                    read();
                }
            });
    }
</script>
